import 'package:cbec_app/components/base/base_image.dart';
import 'package:cbec_app/components/base/base_nav_bar.dart';
import 'package:cbec_app/components/base/base_page.dart';
import 'package:cbec_app/components/common/common_style.dart';
import 'package:cbec_app/components/common/not_found.dart';
import 'package:cbec_app/components/common/sort_flitter_box.dart';
import 'package:cbec_app/components/goods/goods_classify_list.dart';
import 'package:cbec_app/components/goods/goods_item.dart';
import 'package:cbec_app/components/popup/filtter_popup.dart';
import 'package:cbec_app/pages/classify/controller/brand_detail_ctr.dart';
import 'package:cbec_app/routes/routes.dart';
import 'package:cbec_app/utils/Tools.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

//品牌详情
class BrandDetail extends StatelessWidget {
  final String? flag;

  const BrandDetail({super.key, this.flag});

  @override
  Widget build(BuildContext context) {
    final BrandDetailController controller = Get.find(tag: flag);
    controller.baseRefreshCtr = RefreshController(initialRefresh: false);
    return GetBuilder<BrandDetailController>(
        tag: flag,
        builder: (controller) {
          return BasePage(
            bodyColor: Colors.transparent,
            isSearch: true,
            searchType: SearchStyleType.onlySearch,
            iconType: IconType.back,
            routeName: Routes.search,
            refreshController: controller.baseRefreshCtr,
            enablePullDown: true,
            enablePullUp: controller.isLoadData,
            onPageRefresh: controller.onPageRefresh,
            onPageLoading: controller.onPageLoading,
            children: [
              Container(
                height: 80.h,
                child: Stack(
                  children: [
                    Positioned(
                        bottom: 0,
                        child: Container(
                          width: 375.w,
                          height: 50.h,
                          color: Colors.white,
                          padding: EdgeInsets.only(left: 100.w),
                          child: Column(
                            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                            children: [
                              Row(
                                children: [
                                  Text(controller.detail['brandName'].toString(), style: setTextStyle(15, FontWeight.w700, Tools.fromHex("#333333"))),
                                  SizedBox(width: 5.w),
                                  Container(
                                    decoration: border_radis(Tools.fromHex("#FF955D"), radiusValue: 5.w),
                                    padding: EdgeInsets.fromLTRB(4.w, 2.w, 4.w, 2.w),
                                    child: Text("品牌", style: setTextStyle(10, FontWeight.w300, Tools.fromHex("#FFFFFF"))),
                                  )
                                ],
                              ),
                              Row(
                                children: [
                                  Text("商品数量", style: setTextStyle(12, FontWeight.w700, Tools.fromHex("#999999"))),
                                  SizedBox(width: 5.w),
                                  Text(
                                    controller.detail['goodsNum'].toString(),
                                    style: setTextStyle(
                                      12,
                                      FontWeight.w700,
                                      Tools.fromHex("#333333"),
                                    ),
                                  ),
                                ],
                              )
                            ],
                          ),
                        )),
                    Positioned(
                        top: 1,
                        left: 8.w,
                        child: BaseImage(
                          url: controller.detail['image'].toString(),
                          width: 80.w,
                          height: 80.w,
                          borderRadius: BorderRadius.circular(40.w),
                        )),
                  ],
                ),
              ),
              Container(
                padding: EdgeInsets.only(left: 8.w, right: 8.w, top: 10.h, bottom: 20.h),
                color: Tools.fromHex("#F3F5F7"),
                child: controller.goodsList.isNotEmpty
                    ? Wrap(
                        alignment: WrapAlignment.spaceBetween,
                        runSpacing: 6.w,
                        children: controller.goodsList
                            .map((item) => GoodsItem(
                                  goodsInfo: item,
                                ))
                            .toList())
                    : const NotFound(),
              )
            ],
          );
        });
  }
}
